﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EbayMaster
{
    // RichTextBox
    //  http://msdn.microsoft.com/en-us/library/ms744813.aspx
    public partial class FrmItemNote : Form
    {
        public int ItemId = -1;
        public InventoryItemType Item = null;

        public FrmItemNote()
        {
            InitializeComponent();
        }

        private void FrmItemNote_Load(object sender, EventArgs e)
        {
            if (ItemId < 0)
            {
                MessageBox.Show("无效的物品ID", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Item = ItemDAL.GetItemById(ItemId);
            if (Item == null)
            {
                MessageBox.Show("无效的物品ID", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.textBoxItemName.Text = Item.ItemName;
            this.richTextBoxItemNote.Text = Item.ItemNote;
        }

        private void buttonSaveItemNote_Click(object sender, EventArgs e)
        {
            Item.ItemNote = this.richTextBoxItemNote.Text;
            ItemDAL.ModifyItemNote(Item);
            MessageBox.Show("成功保存物品备注", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void buttonReturn_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
